package com.ncase.web.controller.auto;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ncase.common.annotation.Log;
import com.ncase.common.core.controller.BaseController;
import com.ncase.common.core.domain.AjaxResult;
import com.ncase.common.enums.BusinessType;
import com.ncase.auto.domain.NcaseApiWallet;
import com.ncase.auto.service.INcaseApiWalletService;
import com.ncase.common.utils.poi.ExcelUtil;
import com.ncase.common.core.page.TableDataInfo;

/**
 * 钱包管理Controller
 * 
 * @author zouhuu
 * @date 2025-06-02
 */
@RestController
@RequestMapping("/auto/nacseApiWallet")
public class NcaseApiWalletController extends BaseController
{
    @Autowired
    private INcaseApiWalletService ncaseApiWalletService;

    /**
     * 查询钱包管理列表
     */
    @PreAuthorize("@ss.hasPermi('auto:nacseApiWallet:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcaseApiWallet ncaseApiWallet)
    {
        startPage();
        List<NcaseApiWallet> list = ncaseApiWalletService.selectNcaseApiWalletList(ncaseApiWallet);
        return getDataTable(list);
    }

    /**
     * 导出钱包管理列表
     */
    @PreAuthorize("@ss.hasPermi('auto:nacseApiWallet:export')")
    @Log(title = "钱包管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcaseApiWallet ncaseApiWallet)
    {
        List<NcaseApiWallet> list = ncaseApiWalletService.selectNcaseApiWalletList(ncaseApiWallet);
        ExcelUtil<NcaseApiWallet> util = new ExcelUtil<NcaseApiWallet>(NcaseApiWallet.class);
        util.exportExcel(response, list, "钱包管理数据");
    }

    /**
     * 获取钱包管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('auto:nacseApiWallet:query')")
    @GetMapping(value = "/{walletId}")
    public AjaxResult getInfo(@PathVariable("walletId") Long walletId)
    {
        return success(ncaseApiWalletService.selectNcaseApiWalletByWalletId(walletId));
    }

    /**
     * 新增钱包管理
     */
    @PreAuthorize("@ss.hasPermi('auto:nacseApiWallet:add')")
    @Log(title = "钱包管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcaseApiWallet ncaseApiWallet)
    {
        return toAjax(ncaseApiWalletService.insertNcaseApiWallet(ncaseApiWallet));
    }

    /**
     * 修改钱包管理
     */
    @PreAuthorize("@ss.hasPermi('auto:nacseApiWallet:edit')")
    @Log(title = "钱包管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcaseApiWallet ncaseApiWallet)
    {
        return toAjax(ncaseApiWalletService.updateNcaseApiWallet(ncaseApiWallet));
    }

    /**
     * 删除钱包管理
     */
    @PreAuthorize("@ss.hasPermi('auto:nacseApiWallet:remove')")
    @Log(title = "钱包管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{walletIds}")
    public AjaxResult remove(@PathVariable Long[] walletIds)
    {
        return toAjax(ncaseApiWalletService.deleteNcaseApiWalletByWalletIds(walletIds));
    }
}
